QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Saving Movies in Movie Files

The Movie Toolbox allows you to save movies in movie files. Movie files have a file type of 'MooV' . Typically, the movie itself is stored in the resource fork of the movie file. The movie can also be stored in data fork, for use on systems that do not support resource forks. The movie's data may reside in the data fork of the movie file, or in other files.

When you create a new movie, you must create a file to contain the movie data. Use the CreateMovieFile function (described on CreateMovieFile ) to create a new movie file. This function returns a file system reference number that you must use to identify the file to other Movie Toolbox functions. You can add your movie to the file by calling the AddMovieResource function (described on AddMovieResource ). When you are done with the file, you close it by calling the CloseMovieFile function (described on CloseMovieFile ). Your movie is now safely stored in the movie file.

If you are working with an existing movie, you must read that movie from a movie file or choose a movie from the scrap. You first open the movie file by calling the OpenMovieFile function (described on OpenMovieFile ). You then load the movie from that file by calling the NewMovieFromFile function (described on NewMovieFromFile ). Alternatively, you can use the NewMovieFromHandle function (described on NewMovieFromHandle ). After you have edited the movie, you must store it in your file if you want to save your changes. If you want to replace the old movie, use the UpdateMovieResource function (described on UpdateMovieResource ). If you want to keep the old movie, create a new movie by calling the AddMovieResource function described on AddMovieResource (a movie file may contain more than one movie resource). You should then close the movie file by calling the CloseMovieFile function (described on CloseMovieFile ).

The Movie Toolbox maintains a changed flag for each movie your application loads. You can use this flag to determine when to save your movie. The Movie Toolbox sets this flag to true whenever you make a change to a movie that should be saved. You can read this flag by calling the HasMovieChanged function (described on HasMovieChanged ). You can set the flag to false by calling the ClearMovieChanged function (described on ClearMovieChanged ).

The Movie Toolbox provides two functions for deleting movies: DeleteMovieFile and RemoveMovieResource . Use DeleteMovieFile (described on DeleteMovieFile ) to delete a movie file. Use RemoveMovieResource (described on RemoveMovieResource ) to delete a movie from a movie file. Don't use the corresponding standard Macintosh Toolbox routines ( FSpDelete and RmveResource ). The Movie Toolbox maintains movie references between files correctly whereas these routines do not.

The Movie Toolbox allows you to create movie files that contain all of their movie data, rather than containing references to data in other files. This is often desirable when creating a version of a movie that will be moved to another computer. You can use the FlattenMovie or FlattenMovieData functions to resolve all of the data references and create a self-contained movie.

The Movie Toolbox also accommodates operating systems that do not recognize files that contain more than one fork. You can create a movie file that contains the movie and all of its data in the data fork of the movie file. You can then use that file on operating systems that do not recognize resource forks. You can use the FlattenMovie or FlattenMovieData functions to put the movie in the data fork at the same time it creates a self-contained movie file. This would be the usual approach when creating a movie on a Macintosh computer that you want to store on a Unix web server. You can also create a single-fork movie file by calling the CreateMovieFile function with the flag createMovieFileDontCreateResFile . This would be the usual approach when creating movies using QuickTime for Windows.

Your application may allow the user to decide how to save the movie. In this case, you can use a Save As dialog box similar to the one shown in Figure 32 . In this dialog box, the user can elect to create a movie file that contains all of the data for a movie by clicking the "Make movie self-contained" radio button.

Figure 32 A sample movie Save As dialog box


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next